package com.demo.dao;

import com.demo.entity.Manager;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ManagerMapper {
    @Delete({
        "delete from manager",
        "where mname = #{mname,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String mname);

    @Insert({
        "insert into manager (mname, mpwd, ",
        "mrole, college)",
        "values (#{mname,jdbcType=VARCHAR}, #{mpwd,jdbcType=VARCHAR}, ",
        "#{mrole,jdbcType=INTEGER}, #{college,jdbcType=VARCHAR})"
    })
    int insert(Manager record);

    int insertSelective(Manager record);

    @Select({
        "select",
        "mname, mpwd, mrole, college",
        "from manager",
        "where mname = #{mname,jdbcType=VARCHAR}"
    })
    @ResultMap("BaseResultMap")
    Manager selectByPrimaryKey(String mname);

    int updateByPrimaryKeySelective(Manager record);

    @Update({
        "update manager",
        "set mpwd = #{mpwd,jdbcType=VARCHAR},",
          "mrole = #{mrole,jdbcType=INTEGER},",
          "college = #{college,jdbcType=VARCHAR}",
        "where mname = #{mname,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Manager record);

    @Select({
            "select",
            "*",
            "from manager",
            "where mname = #{0} and mpwd=#{1} and mrole=#{2}"
    })
    @ResultMap("BaseResultMap")
    Manager logincheck(String mname,String pwd,int optty);

    @Select({
            "select",
            "*",
            "from manager",
            "where mrole=1"
    })
    @ResultMap("BaseResultMap")
    List<Manager> selectAll();
}